package com.bibrApp.difu.actvity.others;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.bibrApp.difu.R;
import com.bibrApp.difu.actvity.record_mvp.RecordBean;
import com.bibrApp.difu.base.BaseActivity;

import java.io.Serializable;

import butterknife.BindView;
import butterknife.OnClick;

public class RecordDetailActivity extends BaseActivity<OtherPresenter> implements IOtherView {

    private RecordBean bean;

    @BindView(R.id.iv_type)
    ImageView imageView;
    @BindView(R.id.tv_type)
    TextView tvType;
    @BindView(R.id.tv_count)
    TextView tvCount;
    @BindView(R.id.tv_status)
    TextView tvStatus;
    @BindView(R.id.tv_type_info)
    TextView tvTypeInfo;
    @BindView(R.id.tv_status_info)
    TextView tvStatusInfo;
    @BindView(R.id.tv_lian_info)
    TextView tvLianInfo;
    @BindView(R.id.tv_addr_info)
    TextView tvAddrInfo;
    @BindView(R.id.tv_time_info)
    TextView tvTimeInfo;
    @BindView(R.id.tv_addr_key)
    TextView tvAddrKey;
    @BindView(R.id.tv_id_info)
    TextView tvIdInfo;

    @Override
    protected void initPresenter() {
        presenter = new OtherPresenter(this, this);
        presenter.init();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_record_detail;
    }


    @OnClick(R.id.bt_back)
    public void backClick() {
        onBackPressed();
    }

    @Override
    public void error(String msg) {

    }

    @Override
    public void success(String msg) {

    }

    @Override
    public void initView() {
        Intent intent = getIntent();
        bean = (RecordBean) intent.getSerializableExtra("bean");
        int type = intent.getIntExtra("type", 1);
        if (bean.getCoinCode().equals("BTC")) {
            imageView.setImageResource(R.mipmap.img_btc_48);
        } else if (bean.getCoinCode().equals("ETH")) {
            imageView.setImageResource(R.mipmap.img_eth_48);
        } else {
            imageView.setImageResource(R.mipmap.img_usdt_48);
        }
        tvType.setText(bean.getCoinCode());
        tvStatus.setText(bean.getStatus());
        tvCount.setText(bean.getTransactionMoney());
        tvLianInfo.setText(bean.getCoinCode());

        tvTypeInfo.setText(bean.getTransactionType());
        tvIdInfo.setText(bean.getTransactionNo());
        tvTimeInfo.setText(bean.getBlocktime());

        if (type == 1) {
            tvAddrKey.setText("充币地址");
            tvAddrInfo.setText(bean.getInAddress());
        } else {
            tvAddrKey.setText("提币地址");
            tvAddrInfo.setText(bean.getOutAddress());
        }
    }
}
